using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bow : Weapon
{
    public override void HandleShoot()
    {
        bool isUp = true;
        for (int i = 0; i < bulletAmount; i++)
        {
            if (transform.lossyScale.x > 0)
            {
                if (isUp)
                {
                    var bullet = Instantiate(bulletPrefab, transform.position, Quaternion.Euler(0, 0, i * (90 / bulletAmount)));
                    bullet.GetComponent<Arrow>().weapon = this;
                    isUp = !isUp;
                }
                else
                {
                    var bullet = Instantiate(bulletPrefab, transform.position, Quaternion.Euler(0, 0, -(i + 1) * (90 / bulletAmount)));
                    bullet.GetComponent<Arrow>().weapon = this;
                    isUp = !isUp;
                }
            }
            else
            {
                if (isUp)
                {
                    var bullet = Instantiate(bulletPrefab, transform.position, Quaternion.Euler(0, 0, i * (90 / bulletAmount) + 180));
                    bullet.GetComponent<Arrow>().weapon = this;
                    isUp = !isUp;
                }
                else
                {
                    var bullet = Instantiate(bulletPrefab, transform.position, Quaternion.Euler(0, 0, -(i + 1) * (90 / bulletAmount) + 180));
                    bullet.GetComponent<Arrow>().weapon = this;
                    isUp = !isUp;
                }
            }
        }
    }
}
